Repository navigation
Conversation
|
Went through this one carefully and it holds up. The bug is real on >>> ordinal(10**400)
OverflowError: int too large to convert to float
>>> ordinal(-(10**400))
OverflowError: int too large to convert to floatThe cause is exactly as the PR implies: Reordering to try I checked the fallback ordering preserves existing behaviour across the awkward inputs rather than just the happy path:
All match
One note for anyone else verifying this locally: if you have Unrelated to the correctness of this change, but since it touches the same function: #405 is fixing the negative-number suffix ( |
Wkhanex
left a comment
There was a problem hiding this comment.
I checked 18 exact large-integer cases: 10**400 plus endings 1/2/3/11/12/13, each as int, str and Decimal. Every case retained the full decimal digits and correct English suffix. This directly confirms that ordinal selection no longer needs a lossy float conversion. There is also a separate negative-suffix fix in #405; coordinating those changes would preserve both improvements. AI-assisted review on Python 3.12 with English locale hooks, not a full package suite.
ordinal()promises to accept anything thatint()can convert, but it checks the input as a float first. For example,ordinal(10**400 + 1)raisesOverflowError, while passing the same integer as a string orDecimalreturns"+Inf". These are finite values and should receive an ordinal suffix.Changes proposed in this pull request:
__int__but no__float__to work as documented.__int__-only object, plus compatibility checks for fractional values, booleans and invalid integer strings.Testing on Windows with Python 3.12: the 19 new regression cases fail before the fix and pass afterward. The full suite, including doctests, passes with 812 passed and 69 translation-related skips because some compiled catalogs and gettext tools are unavailable. Ruff, Black and Mypy also pass locally; the full prek hook suite and other Python/platform combinations were not run.